import { reactive, ref, computed } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useStore } from 'vuex';

export default function useCreatePlan() {
    const router = useRouter();
    const route = useRoute();
    const store = useStore();
    const planIdFromList = route.query.planId || null;
    const planIdFromStore = computed(() => store.state.plan.planId);

    const planId = computed(() => {
        if (planIdFromList) {
            store.commit('plan/setPlanId', planIdFromList);
            return planIdFromList;
        }
        return planIdFromStore.value;
    });

    return {
        planId,
    };
}
